package com.veer.shop.service.impl.admin;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.page.PageMethod;
import com.veer.shop.mapper.CustomerMapper;
import com.veer.shop.param.CustomerListParam;
import com.veer.shop.pojo.Product;
import com.veer.shop.pojo.ProductStock;
import com.veer.shop.pojo.ResponseData;
import com.veer.shop.pojo.SimpleProduct;
import com.veer.shop.pojo.ValidResult;
import com.veer.shop.repository.CustomerRepository;
import com.veer.shop.result.CustomerRepoResult;
import com.veer.shop.result.CustomerResult;
import com.veer.shop.result.ProductResult;
import com.veer.shop.service.admin.CustomerService;
import com.veer.shop.service.admin.ProductService;
import com.veer.shop.utils.InitUtil;
import com.veer.shop.utils.ResponseUtil;

/**
 * 客户业务实现类
 * 
 * @author WangBin
 * 2020年9月22日-上午9:45:59
 */
@Service
public class AdminCustomerServiceImpl implements CustomerService {
	
	@Autowired
	CustomerMapper customerMapper;
	@Autowired
	CustomerRepository customerRepository;

	/**
	 * 新增|更新商品
	 */
	@Override
	public ResponseData<?> update(Product product) {
		// 校验参数
		ValidResult verifyResult = verifyProduct(product);
		return ResponseUtil.error(verifyResult.getMessage());
	}

	/**
	 * 会员列表
	 * 
	 * @param param
	 * @return
	 */
	@Override
	public ResponseData<?> getList(CustomerListParam param) {
		
		Page page = PageMethod.startPage(param.getPageNo(), param.getPageSize());
		List<CustomerRepoResult> customerList = customerRepository.getList(param);
		return ResponseUtil.successList(page.getTotal(), customerList);
	}

	/**
	 * 删除商品
	 */
	@Override
	public ResponseData<?> delete(String productId) {
		
		return ResponseUtil.success();
	}

	/**
	 * 商品详情
	 */
	@Override
	public ResponseData<?> get(Integer productId) {
		// 客户详情
		return ResponseUtil.error();
	}

	/**
	 * 校验参数合法性
	 * 
	 * @param product
	 * @return
	 */
	private ValidResult verifyProduct(Product product) {
		
		ValidResult result = InitUtil.initFaildMap();
		
		return InitUtil.initSuccMap();
	}
}